package org.dromara.wx.domain.bo;

import org.dromara.wx.domain.WxUser;
import org.dromara.common.core.validate.AddGroup;
import org.dromara.common.core.validate.EditGroup;
import io.github.linpeilie.annotations.AutoMapper;
import lombok.Data;
import jakarta.validation.constraints.*;
import java.util.Date;

import java.io.Serial;
import java.io.Serializable;

/**
 * 微信用户业务对象 wx_user
 *
 * @author yf
 * @date 2024-06-05
 */
@Data
@AutoMapper(target = WxUser.class, reverseConvertGenerate = false)
public class WxUserBo implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;

    /**
     * 用户ID
     */
    @NotNull(message = "用户ID不能为空", groups = {EditGroup.class})
    private Integer id;

    /**
     * 微信用户OpenID
     */
    private String openId;

    /**
     * 用户名称
     */
    private String userName;

    /**
     * 用户昵称
     */
    private String nickname;

    /**
     * 用户类型（默认common）
     */
    private String userType;

    /**
     * 性别（0为男 1为女）
     */
    private String sex;

    /**
     * 头像图片
     */
    private String avatarImage;

    /**
     * 个性签名
     */
    private String signature;

    /**
     * 邮件地址
     */
    private String email;

    /**
     * 手机号
     */
    private String phoneNumber;

    /**
     * 密码
     */
    private String password;

    /**
     * 密码盐
     */
    private String salt;

    /**
     * 积分
     */
    private Integer points;

    /**
     * 用户状态（0为未注册 1为已注册）
     */
    private String status;

    /**
     * 最后登录时间
     */
    private Date lastLoginTime;

    public static final class WxUserBoBuilder {
        private @NotNull(message = "用户ID不能为空", groups = {EditGroup.class}) Integer id;
        private String openId;
        private String userName;
        private @NotBlank(message = "用户昵称不能为空", groups = {AddGroup.class, EditGroup.class}) String nickname;
        private @NotBlank(message = "用户类型不能为空", groups = {AddGroup.class, EditGroup.class}) String userType;
        private String sex;
        private String avatarImage;
        private String signature;
        private String email;
        private @NotBlank(message = "手机号不能为空", groups = {AddGroup.class, EditGroup.class}) String phoneNumber;
        private String password;
        private String salt;
        private Integer points;
        private Date lastLoginTime;

        private WxUserBoBuilder() {
        }

        public static WxUserBoBuilder aXhljWxUserBo() {
            return new WxUserBoBuilder();
        }

        public WxUserBoBuilder withId(Integer id) {
            this.id = id;
            return this;
        }

        public WxUserBoBuilder withOpenId(String openId) {
            this.openId = openId;
            return this;
        }

        public WxUserBoBuilder withUserName(String userName) {
            this.userName = userName;
            return this;
        }

        public WxUserBoBuilder withNickname(String nickname) {
            this.nickname = nickname;
            return this;
        }

        public WxUserBoBuilder withUserType(String userType) {
            this.userType = userType;
            return this;
        }

        public WxUserBoBuilder withSex(String sex) {
            this.sex = sex;
            return this;
        }

        public WxUserBoBuilder withAvatarImage(String avatarImage) {
            this.avatarImage = avatarImage;
            return this;
        }

        public WxUserBoBuilder withSignature(String signature) {
            this.signature = signature;
            return this;
        }

        public WxUserBoBuilder withEmail(String email) {
            this.email = email;
            return this;
        }

        public WxUserBoBuilder withPhoneNumber(String phoneNumber) {
            this.phoneNumber = phoneNumber;
            return this;
        }

        public WxUserBoBuilder withPassword(String password) {
            this.password = password;
            return this;
        }

        public WxUserBoBuilder withSalt(String salt) {
            this.salt = salt;
            return this;
        }

        public WxUserBoBuilder withPoints(Integer points) {
            this.points = points;
            return this;
        }

        public WxUserBoBuilder withLastLoginTime(Date lastLoginTime) {
            this.lastLoginTime = lastLoginTime;
            return this;
        }

        public WxUserBo build() {
            WxUserBo xhljWxUserBo = new WxUserBo();
            xhljWxUserBo.setId(id);
            xhljWxUserBo.setOpenId(openId);
            xhljWxUserBo.setUserName(userName);
            xhljWxUserBo.setNickname(nickname);
            xhljWxUserBo.setUserType(userType);
            xhljWxUserBo.setSex(sex);
            xhljWxUserBo.setAvatarImage(avatarImage);
            xhljWxUserBo.setSignature(signature);
            xhljWxUserBo.setEmail(email);
            xhljWxUserBo.setPhoneNumber(phoneNumber);
            xhljWxUserBo.setPassword(password);
            xhljWxUserBo.setSalt(salt);
            xhljWxUserBo.setPoints(points);
            xhljWxUserBo.setLastLoginTime(lastLoginTime);
            return xhljWxUserBo;
        }
    }
}
